import { create, update, remove, query } from '../../../../../framework/service/index';

export default {

  namespace: 'contactService',

  state: {
    date: [],
    phone: '13645785788',
    specialPlane: '020-87533689',
    email: '132465@qq.com',
    QQcode: '132465',
    Message: '',
    htmlData:''
  },

  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(location => {
        if(location.pathname === '/contact-service') {
          dispatch({
            type: 'query',
          })
        }
      })
    },
  },



  effects: {
    *query({ payload }, { call, put }) {
      const { code, data, message } = yield call(query, '/api/term/config/bytype/CONTACT', {});
      // console.log("code",JSON.stringify(code));
      // console.log("data",JSON.stringify(data));
      // console.log("message",JSON.stringify(message));
      if(code == 200){
        yield put({
          type: 'querySuccess',
          payload: {
            htmlData:data,
          }
        })
      }
    }
  },

  reducers: {
    querySuccess(state, action) {
      return { ...state, ...action.payload };
    },
  }

};
